#include "DropQuery.h"

#include <iostream>
using namespace std;

DropQuery::DropQuery(void)
{
}

DropQuery::DropQuery(const QueryInfo & q) : SQLQuery(q.type)
{
	this->SetTablename(q.table_name[0]);
	queryInfo = q;
}

RowSet DropQuery::Execute()
{
	RowSet s;
	
	int i;
	
	for(i = 0 ; i <(int) tableInfos.size() ; i++)
	{

		if(tableInfos[i].tableName == this->GetTablename())
			break;
	}
	std::vector<TABLE_INFO> temp;
	int j;
	int size  = (int)tableInfos.size();
	for(j = 0 ; j < size ; j++ )
		temp.push_back(tableInfos[j]);
	tableInfos.clear();
	for(j = 0 ; j < size ; j ++ )
	{
		if(j != i)
			tableInfos.push_back(temp[j]);
	}
	std::string tableFileName = temp[i].tableName + ".db";
	DBDestroyFile(tableFileName.c_str());
	return s;
}


DropQuery::~DropQuery(void)
{
}

